<template>
  <div>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-card shadow="hover" class="mgb20" style="height:252px;">
          <div class="user-info">
            <img src="../assets/img/img.jpg" class="user-avator" alt/>
            <div class="user-info-cont">
              <div class="user-info-name">{{ userInfo.userName }}</div>
              <div>{{ userInfo.userRole }}</div>
            </div>
          </div>
          <div class="user-info-list">
            <span>专业：{{ userInfo.major }}</span>
          </div>
          <div class="user-info-list">
            <span>所属学院：{{ userInfo.college }}</span>
          </div>
        </el-card>

      </el-col>
      <el-col :span="16">
<!--        <el-row :gutter="20" class="mgb20">-->
<!--          <el-col :span="8">-->
<!--            <el-card shadow="hover" :body-style="{ padding: '0px' }">-->
<!--              <div class="grid-content grid-con-1">-->
<!--                <i class="el-icon-user-solid grid-con-icon"></i>-->
<!--                <div class="grid-cont-right">-->
<!--                  <div class="grid-num">1234</div>-->
<!--                  <div>用户访问量</div>-->
<!--                </div>-->
<!--              </div>-->
<!--            </el-card>-->
<!--          </el-col>-->
<!--          <el-col :span="8">-->
<!--            <el-card shadow="hover" :body-style="{ padding: '0px' }">-->
<!--              <div class="grid-content grid-con-2">-->
<!--                <i class="el-icon-message-solid grid-con-icon"></i>-->
<!--                <div class="grid-cont-right">-->
<!--                  <div class="grid-num">321</div>-->
<!--                  <div>系统消息</div>-->
<!--                </div>-->
<!--              </div>-->
<!--            </el-card>-->
<!--          </el-col>-->
<!--          <el-col :span="8">-->
<!--            <el-card shadow="hover" :body-style="{ padding: '0px' }">-->
<!--              <div class="grid-content grid-con-3">-->
<!--                <i class="el-icon-s-goods grid-con-icon"></i>-->
<!--                <div class="grid-cont-right">-->
<!--                  <div class="grid-num">5000</div>-->
<!--                  <div>数量</div>-->
<!--                </div>-->
<!--              </div>-->
<!--            </el-card>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <el-card shadow="hover" style="height:403px;">
          <template #header>
            <div class="clearfix">
              <span>我的课程</span>
<!--              <el-button style="float: right; padding: 3px 0" type="text">添加</el-button>-->
            </div>
          </template>

          <el-table :data="todoList" style="width:100%;">
            <el-table-column label="考试科目">
              <template #default="scope">{{ scope.row.examSubject }}</template>
            </el-table-column>
            <el-table-column label="考试时间" align="center" >
              <template #default="scope" style="width: 150px">
                {{ scope.row.examDates }}
              </template>
            </el-table-column>
            <el-table-column label="考试要求">
              <template #default="scope">{{ scope.row.examIntroduce }}</template>
            </el-table-column>
            <el-table-column label="考试地点">
              <template #default="scope">{{ scope.row.examPosition }}</template>
            </el-table-column>
            <el-table-column prop="address" label="考试时长">
              <template #default="scope">{{ scope.row.examTime }}</template>
            </el-table-column>
            <el-table-column prop="date" label="监考教师">
              <template #default="scope">{{ scope.row.examTeacher }}</template>
            </el-table-column>
            <el-table-column prop="date" label="考试状态">
              <template #default="scope">{{ scope.row.examStatus }}</template>
            </el-table-column>
          </el-table>
        </el-card>
        <el-card shadow="hover" style="height:403px;" v-model="teacherVisible">
          <template #header>
            <div class="clearfix">
              <span>我的监考</span>
              <!--              <el-button style="float: right; padding: 3px 0" type="text">添加</el-button>-->
            </div>
          </template>
          <el-table :data="todoList2" style="width:100%;">
            <el-table-column label="考试科目">
              <template #default="scope">{{ scope.row.examSubject }}</template>
            </el-table-column>
            <el-table-column label="考试时间" align="center" >
              <template #default="scope" style="width: 150px">
                {{ scope.row.examDates }}
              </template>
            </el-table-column>
            <el-table-column label="考试要求">
              <template #default="scope">{{ scope.row.examIntroduce }}</template>
            </el-table-column>
            <el-table-column label="考试地点">
              <template #default="scope">{{ scope.row.examPosition }}</template>
            </el-table-column>
            <el-table-column prop="address" label="考试时长">
              <template #default="scope">{{ scope.row.examTime }}</template>
            </el-table-column>
            <el-table-column prop="date" label="监考教师">
              <template #default="scope">{{ scope.row.examTeacher }}</template>
            </el-table-column>
            <el-table-column prop="date" label="考试状态">
              <template #default="scope">{{ scope.row.examStatus }}</template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
<!--    <el-row :gutter="20">-->
<!--      <el-col :span="12">-->
<!--        <el-card shadow="hover">-->
<!--          <schart ref="bar" class="schart" canvasId="bar" :options="options"></schart>-->
<!--        </el-card>-->
<!--      </el-col>-->
<!--      <el-col :span="12">-->
<!--        <el-card shadow="hover">-->
<!--          <schart ref="line" class="schart" canvasId="line" :options="options2"></schart>-->
<!--        </el-card>-->
<!--      </el-col>-->
<!--    </el-row>-->
  </div>
</template>

<script>
import Schart from "vue-schart";
import {reactive} from "vue";
import {queryMyExams,getUserInfo,selectMySubjectByParam,queryTeacherExamInfo} from "../api/index";

export default {
  name: "dashboard",
  components: {Schart},
  data(){
    return{
      mySubject:{},
      userInfo:{
        userName:'吴秀波',
        userRole:'学生',
        college:'金融',
        major:'金融工程',
      },
      todoList:[{
        examSubject: '',
        examIntroduce: '',
        examPosition: '',
        examTeacher: '',
        examTime: '',
        examDates: '',
        examStatus:''
      }],
      todoList2:[{
        examSubject: 'java',
        examIntroduce: 'java结课考试',
        examPosition: '教学楼1101',
        examTeacher: '吴秀波',
        examTime: '90分钟',
        examDates: '2022-07-01 9:00',
        examStatus:'未开始'
      }],
      teacherVisible:false,
    }
  },
  methods:{
    getUserInfo(){
      getUserInfo().then(res => {
        if(res.code === '200'){
          this.userInfo = res.data;
        }
      })
    },
    getMyExamInfos(){
      if(this.userInfo.userRole === 'student'){
        queryMyExams().then(res => {
          if(res.code === '200'){
            this.todoList = res.data;
            this.$message.success(res.message);
          }else{
            this.$message.error(res.message);
          }
        })
      }else {
        queryTeacherExamInfo().then(res => {
          if(res.code === '200'){
            this.todoList2 = res.data;
          }
        })
      }
    }
  },
  mounted() {
    this.getUserInfo();
    this.getMyExamInfos();
  }
};
</script>

<style scoped>
.el-row {
  margin-bottom: 20px;
}

.grid-content {
  display: flex;
  align-items: center;
  height: 100px;
}

.grid-cont-right {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: #999;
}

.grid-num {
  font-size: 30px;
  font-weight: bold;
}

.grid-con-icon {
  font-size: 50px;
  width: 100px;
  height: 100px;
  text-align: center;
  line-height: 100px;
  color: #fff;
}

.grid-con-1 .grid-con-icon {
  background: rgb(45, 140, 240);
}

.grid-con-1 .grid-num {
  color: rgb(45, 140, 240);
}

.grid-con-2 .grid-con-icon {
  background: rgb(100, 213, 114);
}

.grid-con-2 .grid-num {
  color: rgb(45, 140, 240);
}

.grid-con-3 .grid-con-icon {
  background: rgb(242, 94, 67);
}

.grid-con-3 .grid-num {
  color: rgb(242, 94, 67);
}

.user-info {
  display: flex;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 2px solid #ccc;
  margin-bottom: 20px;
}

.user-avator {
  width: 120px;
  height: 120px;
  border-radius: 50%;
}

.user-info-cont {
  padding-left: 50px;
  flex: 1;
  font-size: 14px;
  color: #999;
}

.user-info-cont div:first-child {
  font-size: 30px;
  color: #222;
}

.user-info-list {
  font-size: 14px;
  color: #999;
  line-height: 25px;
}

.user-info-list span {
  margin-left: 70px;
}

.mgb20 {
  margin-bottom: 20px;
}

.todo-item {
  font-size: 14px;
}

.todo-item-del {
  text-decoration: line-through;
  color: #999;
}

.schart {
  width: 100%;
  height: 300px;
}
</style>
